{template admin/header}
<script src="static/js/date/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript">
    function checkinput() {
        if (document.getElementById('title').value == '') {
            MessageBox('notice', "标题不能为空", '提示');
            return false;
        }
        if (document.getElementById('answer').value == '') {
            MessageBox('notice', "答案不能为空", '提示');
            return false;
        }
        var identity_count = 0;
        $(".identity").each(function(){
            if($(this).val() == ''){
                identity_count++;
                
            }
        });
        if(identity_count > 0){
            MessageBox('notice', "选择不能为空", '提示');
            return false;
        }
        var answer_txt_count = 0;
        $(".answer_txt").each(function(){
            if($(this).val() == ''){
                answer_txt_count++;
            }
        });
        if(answer_txt_count > 0){
            MessageBox('notice', "选项内容不能为空", '提示');
            return false;
        }
    }
    
</script>
<div class="mt10">
<style type="text/css">
    .radio_uid{margin: 10px;}
</style>
    <form action="{$action}" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return checkinput()">
        <table cellspacing="1" cellpadding="4" width="100%" align="center" class="tableborder">
            <tr class="header">
                <td colspan="2">{$title}</td>
            </tr>
            <tr>
                <td width="13%" bgcolor="#F8F8F8">&nbsp;</td>
                <td width="87%" bgcolor="#FFFFFF">&nbsp;</td>
            </tr>

            <tr>
                <td class="altbg1" width="13%" bgcolor="#F8F8F8">题目</td>
                <td class="altbg2" width="87%" align="right" bgcolor="#FFFFFF">
                    <input type="text" id="title" name="title" maxlength="30">
                </td>
            </tr>
            <tr>
                <td class="altbg1" width="13%" bgcolor="#F8F8F8">答案</td>
                <td class="altbg2" width="87%" align="right" bgcolor="#FFFFFF">
                    <input type="text" id="answer" name="answer" maxlength="30" placeholder="A">
                </td>
            </tr>
            <tr>
                <td class="altbg1" width="13%" bgcolor="#F8F8F8">选项<input type="text" name="identity[]" maxlength="30" placeholder="A" class="identity"></td>
                <td class="altbg2" width="87%" align="right" bgcolor="#FFFFFF"><input type="text" name="answer_txt[]" maxlength="30" placeholder="选项内容" class="answer_txt"></td>
            </tr>
            <tr>
                <td width="40%" bgcolor="#F8F8F8" colspan="2"><span class="button add_module">添加选项</span></td>
            </tr>
        </table>
        <br>
        <center><input type="submit" class="button" id="submit" name="addsubmit" value="保 存"></center>

    </form>

</div>
<script type="text/javascript">
    $(function() {
        $(".add_module").click(function(){
            add_module();
            return false;
        });
    })
    function add_module(){
        var module_html = '';
        module_html += '<tr>';
        module_html += '<td class="altbg1" width="13%" bgcolor="#F8F8F8">选项<input type="text" name="identity[]" maxlength="30" placeholder="A" class="identity"></td>';
        module_html += '<td class="altbg2" width="87%" align="right" bgcolor="#FFFFFF"><input type="text" name="answer_txt[]" maxlength="30" placeholder="选项内容" class="answer_txt"></td>';
        module_html += '</tr>';
        $(".add_module").parent().parent().before(module_html);
    }
</script>
